home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.3 / Printer / src / EpsonX / dospecial.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  4.7 KB  |  221 lines

  1. /*
  2.     DoSpecial for EpsonX driver.
  3.     David Berezowski - March/88.
  4.  
  5.   Copyright (c) 1988 Commodore-Amiga, Inc.
  6.  
  7.   Executables based on this information may be used in software
  8.   for Commodore Amiga computers.  All other rights reserved.
  9.  
  10.   This information is provided "as is"; no warranties are made.
  11.   All use is at your own risk, and no liability or responsibility is assumed.
  12. */
  13.  
  14.  
  15. #include "exec/types.h"
  16. #include "../printer/printer.h"
  17. #include "../printer/prtbase.h"
  18.  
  19. #define LMARG    3
  20. #define RMARG    6
  21. #define MARGLEN    8
  22.  
  23. #define CONDENSED    7
  24. #define PITCH        9
  25. #define QUALITY        17
  26. #define LPI        24
  27. #define INITLEN        26
  28.  
  29. DoSpecial(command, outputBuffer, vline, currentVMI, crlfFlag, Parms)
  30. char outputBuffer[];
  31. UWORD *command;
  32. BYTE *vline;
  33. BYTE *currentVMI;
  34. BYTE *crlfFlag;
  35. UBYTE Parms[];
  36. {
  37.     extern struct PrinterData *PD;
  38.  
  39.     int x = 0, y = 0;
  40.     /*
  41.         00-00    \375    wait
  42.         01-03    \033lL    set left margin
  43.         04-06    \033Qq    set right margin
  44.         07-07    \375    wait
  45.     */
  46.     static char initMarg[MARGLEN] = "\375\033lL\033Qq\375";
  47.     /*
  48.         00-01    \0335        italics off
  49.         02-04    \033-\000    underline off
  50.         05-06    \033F        boldface off
  51.         07-07    \022        cancel condensed mode
  52.         08-09    \033P        select pica (10 cpi)
  53.         10-12    \033W\000    enlarge off
  54.         13-14    \033H        doublestrike off
  55.         15-17    \033x\000    draft
  56.         18-19    \033T        super/sub script off
  57.         20-22    \033p0        proportional off
  58.         23-24    \0332        6 lpi
  59.         25-25    \015        carriage return
  60.     */
  61.     static char initThisPrinter[INITLEN] =
  62. "\0335\033-\000\033F\022\033P\033W\000\033H\033x\000\033T\033p0\0332\015";
  63.     static BYTE ISOcolorTable[10] = {0, 5, 6, 4, 3, 1, 2, 0};
  64.  
  65.     if (*command == aRIN) {
  66.         while (x < INITLEN) {
  67.             outputBuffer[x] = initThisPrinter[x];
  68.             x++;
  69.         }
  70.  
  71.         if (PD->pd_Preferences.PrintQuality == LETTER) {
  72.             outputBuffer[QUALITY] = 1;
  73.         }
  74.  
  75.         *currentVMI = 36; /* assume 1/6 line spacing (36/216 => 1/6) */
  76.         if (PD->pd_Preferences.PrintSpacing == EIGHT_LPI) {
  77.             outputBuffer[LPI] = '0';
  78.             *currentVMI = 27; /* 27/216 => 1/8 */
  79.         }
  80.  
  81.         if (PD->pd_Preferences.PrintPitch == ELITE) {
  82.             outputBuffer[PITCH] = 'M';
  83.         }
  84.         else if (PD->pd_Preferences.PrintPitch == FINE) {
  85.             outputBuffer[CONDENSED] = '\017'; /* condensed */
  86.             outputBuffer[PITCH] = 'P'; /* pica condensed */
  87.         }
  88.  
  89.         Parms[0] = PD->pd_Preferences.PrintLeftMargin;
  90.         Parms[1] = PD->pd_Preferences.PrintRightMargin;
  91.         *command = aSLRM;
  92.     }
  93.  
  94.     if (*command == aCAM) { /* cancel margins */
  95.         y = PD->pd_Preferences.PaperSize == W_TRACTOR ? 136 : 80;
  96.         if (PD->pd_Preferences.PrintPitch == PICA) {
  97.             Parms[1] = (10 * y) / 10;
  98.         }
  99.         else if (PD->pd_Preferences.PrintPitch == ELITE) {
  100.             Parms[1] = (12 * y) / 10;
  101.         }
  102.         else { /* fine */
  103.             Parms[1] = (17 * y) / 10;
  104.         }
  105.         Parms[0] = 1;
  106.         y = 0;
  107.         *command = aSLRM;
  108.     }
  109.  
  110.     if (*command == aSLRM) { /* set left and right margins */
  111.         PD->pd_PWaitEnabled = 253;
  112.         if (Parms[0] == 0) {
  113.             initMarg[LMARG] = 0;
  114.         }
  115.         else {
  116.             initMarg[LMARG] = Parms[0] - 1;
  117.         }
  118.         initMarg[RMARG] = Parms[1];
  119.         while (y < MARGLEN) {
  120.             outputBuffer[x++] = initMarg[y++];
  121.         }
  122.         return(x);
  123.     }
  124.  
  125.     if (*command == aPLU) {
  126.         if (*vline == 0) {
  127.             *vline = 1;
  128.             *command = aSUS2;
  129.             return(0);
  130.         }
  131.         if (*vline < 0) {
  132.             *vline = 0;
  133.             *command = aSUS3;
  134.             return(0);
  135.         }
  136.         return(-1);
  137.     }
  138.  
  139.     if (*command == aPLD) {
  140.         if (*vline == 0) {
  141.             *vline = -1;
  142.             *command = aSUS4;
  143.             return(0);
  144.         }
  145.         if (*vline > 0) {
  146.             *vline = 0;
  147.             *command = aSUS1;
  148.             return(0);
  149.         }
  150.         return(-1);
  151.     }
  152.  
  153.     if (*command == aSUS0) {
  154.         *vline = 0;
  155.     }
  156.     if (*command == aSUS1) {
  157.         *vline = 0;
  158.     }
  159.     if (*command == aSUS2) {
  160.         *vline = 1;
  161.     }
  162.     if (*command == aSUS3) {
  163.         *vline = 0;
  164.     }
  165.     if (*command == aSUS4) {
  166.         *vline = -1;
  167.     }
  168.  
  169.     if (*command == aVERP0) {
  170.         *currentVMI = 27;
  171.     }
  172.  
  173.     if (*command == aVERP1) {
  174.         *currentVMI = 36;
  175.     }
  176.  
  177.     if (*command == aIND) { /* lf */
  178.         outputBuffer[x++] = '\033';
  179.         outputBuffer[x++] = 'J';
  180.         outputBuffer[x++] = *currentVMI;
  181.         return(x);
  182.     }
  183.  
  184.     if (*command == aRI) { /* reverse lf */
  185.         outputBuffer[x++] = '\033';
  186.         outputBuffer[x++] = 'j';
  187.         outputBuffer[x++] = *currentVMI;
  188.         return(x);
  189.     }
  190.  
  191.     if (*command == aSFC) {
  192.         if (Parms[0] == 39) {
  193.             Parms[0] = 30; /* set defaults */
  194.         }
  195.         if (Parms[0] > 37) {
  196.             return(0); /* ni or background color change */
  197.         }
  198.         outputBuffer[x++] = '\033';
  199.         outputBuffer[x++] = 'r';
  200.         outputBuffer[x++] = ISOcolorTable[Parms[0] - 30];
  201.         /*
  202.         Kludge to get this to work on a CBM_MPS-1250  which interprets
  203.         'ESCr' as go into reverse print mode.  The 'ESCt' tells it to
  204.         get out of reverse print mode.  The 'NULL' is ignored by the
  205.         CBM_MPS-1250 and required by all Epson printers as the
  206.         terminator for the 'ESCtNULL' command which means select
  207.         normal char set (which has no effect).
  208.         */
  209.         outputBuffer[x++] = '\033';
  210.         outputBuffer[x++] = 't';
  211.         outputBuffer[x++] = 0;
  212.         return(x);
  213.     }
  214.  
  215.     if (*command == aRIS) {
  216.         PD->pd_PWaitEnabled = 253;
  217.     }
  218.  
  219.     return(0);
  220. }
  221.